package com.cogent.report.display.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import com.cogent.common.util.MapUtil;
import com.cogent.dynamicform.cache.EnumCacheManager;
import com.cogent.report.display.IReportDisplay;
import com.cogent.report.domain.ReportDisplayFieldDomain;

public class MutiEnumDisplayImpl implements IReportDisplay {	
	public String getDisplayValue(ReportDisplayFieldDomain displayFieldDomain, HashMap dataMap) {
		StringBuffer str = new StringBuffer();
		List enmuList = (List)EnumCacheManager.get(displayFieldDomain.getTypecode() + "!LIST");
		Iterator it = enmuList.iterator();
		String curvalue = MapUtil.getStringValue(dataMap, displayFieldDomain.getName());
		while(it.hasNext()) {
			HashMap map = (HashMap)it.next();
			String val = MapUtil.getStringValue(map, "value");
			if(curvalue.indexOf("," + val + ",") >= 0)
				str.append(MapUtil.getStringValue(map, "enumitemname")).append(",");
		}
		String ret = str.toString();
		if(ret.length()>0)
			ret = ret.substring(0, ret.length()-1);
		
		return ret;
	}
}
